
import dayjs from 'dayjs'
import type Console from 'console'

interface loggerOptions {
  scope: string
}

export default class Logger {
  scope = 'app'

  constructor (options: loggerOptions = { scope: 'app' }) {
    this.scope = options.scope
  }

  log (): Console['log'] {
    return console.log.bind(console, `[${this.scope}][${dayjs().format('HH:mm:ss')}]`, ...arguments)
  }

  info (): Console['info'] {
    return console.info.bind(console, `[${this.scope}][${dayjs().format('HH:mm:ss')}]`, ...arguments)
  }

  warn (): Console['warn'] {
    return console.warn.bind(console, `[${this.scope}][${dayjs().format('HH:mm:ss')}]`, ...arguments)
  }

  error (): Console['error'] {
    return console.error.bind(console, `[${this.scope}][${dayjs().format('HH:mm:ss')}]`, ...arguments)
  }
}
